package subject_set.offer100;

/**
 * @author haomin
 * @date 2022/10/20 20:43
 **/
public class Offer42 {
    class Solution {
        public int maxSubArray(int[] nums) {
            if(nums.length == 0) return 0;
            int max = nums[0];
            for(int i = 1; i < nums.length; ++i){
                nums[i] = Math.max(nums[i-1]+nums[i], nums[i]);
                max = Math.max(max, nums[i]);
            }
            return max;
        }
    }
}